//
//  MainVC_Mine_Button.m
//  liBaQiang
//
//  Created by 奇林刘 on 2018/10/11.
//  Copyright © 2018年 liu. All rights reserved.
//

#import "MainVC_Mine_Button.h"

@interface MainVC_Mine_Button ()

@property (nonatomic, strong) UIView *lineTop;
@property (nonatomic, strong) UIImageView *logoImageView;
@property (nonatomic, strong) UILabel *title;
@property (nonatomic, strong) UIImageView *rightImageView;
@property (nonatomic, strong) UIView *lineBottom;

@end

@implementation MainVC_Mine_Button {
    NSString *_logoImageString;
    NSString *_titleString;
}

- (instancetype)initWithLogoImageName:(NSString *)name title:(NSString *)title {
    _logoImageString = name;
    _titleString = title;
    self = [super init];
    return self;
}

- (void)configSelf {
    self.fp_backgroundColor([UIColor whiteColor]);
    [self mas_makeConstraints:^(MASConstraintMaker *make) {
        make.width.equalTo(@(RPX(375)));
        make.height.equalTo(@(RPX(49)));
    }];
}

- (void)allocateComponents {
    [self allocateLineTop];
    [self allocateLogoImageView];
    [self allocateTitle];
    [self allocateRightImageView];
    [self allocateLineBottom];
}

- (void)configComponents {
    [self configLineTop];
    [self configLogoImageView];
    [self configTitle];
    [self configRightImageView];
    [self configLineBottom];
}

#pragma mark - usedMethods
- (void)allocateLineTop {
    self.fp_addSubview(self.lineTop=[[UIView alloc]init]);
    [self.lineTop mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.left.right.equalTo(self);
        make.height.equalTo(@(0.5));
    }];
}

- (void)allocateLogoImageView {
    self.fp_addSubview(self.logoImageView=[[UIImageView alloc]init]);
    [self.logoImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self).offset(RPX(15));
        make.centerY.equalTo(self);
        make.width.height.equalTo(@(RPX(20)));
    }];
}

- (void)allocateTitle {
    self.fp_addSubview(self.title=[[UILabel alloc] init]);
    [self.title mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(self);
        make.left.equalTo(self.logoImageView.mas_right).offset(RPX(17));
    }];
}

- (void)allocateRightImageView {
    self.fp_addSubview(self.rightImageView=[[UIImageView alloc]init]);
    [self.rightImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(self).offset(RPX(-15));
        make.centerY.equalTo(self);
        make.width.equalTo(@(RPX(7)));
        make.height.equalTo(@(RPX(13)));
    }];
}

- (void)allocateLineBottom {
    self.fp_addSubview(self.lineBottom=[[UIView alloc]init]);
    [self.lineBottom mas_makeConstraints:^(MASConstraintMaker *make) {
        make.bottom.left.right.equalTo(self);
        make.height.equalTo(@(0.5));
    }];
}

- (void)configLineTop {
    self.lineTop.fp_backgroundColor(HexadecimalColor(@"#EBEBEB"));
}

- (void)configLogoImageView {
    self.logoImageView.fp_contentMode(UIViewContentModeScaleAspectFit);
    [self.logoImageView setImage:[UIImage imageNamed:_logoImageString]];
}

- (void)configTitle {
    self.title.fp_font(RPXFont(16))
        .fp_text(_titleString);
}

- (void)configRightImageView {
    self.rightImageView.fp_contentMode(UIViewContentModeScaleAspectFit);
    [self.rightImageView setImage:[UIImage imageNamed:@"right"]];
}

- (void)configLineBottom {
    self.lineBottom.fp_backgroundColor(HexadecimalColor(@"#EBEBEB"));
}

@end
